#pragma once
#include<string>
#include<iostream>
#include<map>

class Car
{
	public:
	/*
	 注意：大臂小臂控制需准确，相互角度差距过大会导致舵机锁死过热
	 */
	Car();
	void message_deal(std::string data,int deliver);
	/*调用该函数可以直接调用类内函数，data值为map对应字符串,deliver值为下列函数对应参数*/
	void forward(int speed);//前进,区间(0,100)
	void backward(int speed);//后退,区间(0,100)
	void left_turn(int speed);//左转,区间(0,100)
	void right_turn(int speed);//右转,区间(0,100)
	void left_forward(int speed);//左前方,区间(0,100)
	void right_forward(int speed);//右前方,区间(0,100)
	void left_back(int speed);//左后方,区间(0,100)
	void right_back(int speed);//右后方,区间(0,100)
	void big_arm(int angle);//大臂,区间(0,120)
	void small_arm(int angle);//小臂,区间(0,120)
	void plateform(int angle);//平台,区间(0,160)
	void handle(int angle);//夹子,区间(10,30)
	void stop(int joke);//停止,joke为任意值
	private:
	typedef void (Car::*func)(int tar);//此处map内字符串函数一一对应
	std::map<std::string,func>deal_map={
		{"advance",&Car::forward},
		{"Back_off",&Car::backward},
		{"turn_left",&Car::left_turn},
		{"turn_right",&Car::right_turn},
		{"left_advance",&Car::left_forward},
		{"right_advance",&Car::right_forward},
		{"left_back",&Car::left_back},
		{"right_back",&Car::right_back},
		{"Foream",&Car::small_arm},
		{"Big_Arm",&Car::big_arm},
		{"plateform",&Car::plateform},
		{"clip",&Car::handle},
		{"stop",&Car::stop}
	};
};
